home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / comm / tcp / Amster.lha / Amster_Install / Source / hotlist.c < prev    next >
C/C++ Source or Header  |  2000-07-31  |  15KB  |  530 lines

  1. /*
  2. ** Amster - Hotlist
  3. ** by Jacob Laursen <laursen@myself.com>
  4. */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9.  
  10. #include <proto/dos.h>
  11. #include <proto/socket.h>
  12. #include <proto/utility.h>
  13.  
  14. #include <netdb.h>
  15. #include <sys/time.h>
  16. #include <sys/socket.h>
  17. #include <sys/ioctl.h>
  18. #include <netinet/tcp.h>
  19. #include <bsdsocket/socketbasetags.h>
  20. #include <error.h>
  21. #include <time.h>
  22.  
  23. #include <MUI/Lamp_mcc.h>
  24. #include <MUI/NListview_mcc.h>
  25.  
  26. #include "include/config.h"
  27. #include "include/gui.h"
  28. #include "include/info.h"
  29. #include "include/mui.h"
  30. #include "include/hotlist.h"
  31. #include "include/prefs.h"
  32. #include "include/search.h"
  33. #include "include/resultview.h"
  34. #include "include/share.h"
  35.  
  36. #include "include/protos.h"
  37. #include "amster_Cat.h"
  38.  
  39. /* Global variables */
  40.  
  41. BOOL HotlistChanged = FALSE;
  42.  
  43. int browse_count = 0;
  44. int browse_state = 0;
  45.  
  46.  
  47. /* Private prototypes */
  48.  
  49. MUIF HotlistDisplay(REG(a2) char **array, REG(a1) struct HotlistEntry *entry);
  50. MUIF HotlistCompare(REG(a0) struct Hook *hook, REG(a2) Object *obj, REG(a1) struct NList_CompareMessage *ncm);
  51. MUIF HotlistDestruct(REG(a2) APTR pool, REG(a1) struct HotlistEntry *entry);
  52. void LoadHotlist(struct HotlistData *data);
  53. void SaveHotlist(struct HotlistData *data);
  54. void UploadHotlist(struct HotlistData *data);
  55. struct HotlistEntry *GetHotlistEntry(struct HotlistData *data, char *nick);
  56.  
  57.  
  58. MUIF HotlistDispatch(REG(a0) struct IClass *cl, REG(a2) Object *obj, REG(a1) Msg msg)
  59. {
  60.     struct HotlistData *data;
  61.  
  62.     switch (msg->MethodID) {
  63.         case OM_NEW:
  64.             return(HotlistNew(cl, obj, (APTR)msg));
  65.         case HOTLIST_LOAD:
  66.             data = INST_DATA(cl, obj);
  67.             LoadHotlist(data);
  68.             return NULL;
  69.         case HOTLIST_SAVE:
  70.             data = INST_DATA(cl, obj);
  71.             SaveHotlist(data);
  72.             return NULL;
  73.         case HOTLIST_UPLOAD:
  74.             data = INST_DATA(cl, obj);
  75.             UploadHotlist(data);
  76.             return NULL;
  77.         case HOTLIST_CLEAR:
  78.             data = INST_DATA(cl, obj);
  79.             DoMethod(data->LV_Search, RESULTVIEW_CLEAR, (((muimsg)msg)->arg1));
  80.             return NULL;
  81.         case HOTLIST_SIGNON:
  82.             {
  83.             long pos;
  84.             struct HotlistEntry *entry;
  85.  
  86.             data = INST_DATA(cl, obj);
  87.             if (entry = GetHotlistEntry(data, (char *)(((muimsg)msg)->arg1))) {
  88.                 entry->Online = 1;
  89.                 if ((int)(((muimsg)msg)->arg2) != entry->Speed) {
  90.                     entry->Speed = (int)(((muimsg)msg)->arg2);
  91.                     HotlistChanged = TRUE;
  92.                 }
  93.                 pos = MUIV_NList_GetPos_Start;
  94.                 DoMethod(data->LV_Hotlist, MUIM_NList_GetPos, entry, &pos);
  95.                 DoMethod(data->LV_Hotlist, MUIM_NList_Redraw, pos);
  96.                 DoMethod(data->LV_Hotlist, MUIM_NList_Sort);
  97.             }
  98.             return NULL;
  99.             }
  100.         case HOTLIST_SIGNOFF:
  101.             {
  102.             long pos;
  103.             struct HotlistEntry *entry;
  104.  
  105.             data = INST_DATA(cl, obj);
  106.             if (entry = GetHotlistEntry(data, (char *)(((muimsg)msg)->arg1))) {
  107.                 entry->Online = 0;
  108.                 pos = MUIV_NList_GetPos_Start;
  109.                 DoMethod(data->LV_Hotlist, MUIM_NList_GetPos, entry, &pos);
  110.                 DoMethod(data->LV_Hotlist, MUIM_NList_Redraw, pos);
  111.                 DoMethod(data->LV_Hotlist, MUIM_NList_Sort);
  112.             }
  113.             return NULL;
  114.             }
  115.         case HOTLIST_SIGNOFF_ALL:
  116.             {
  117.             int i;
  118.             struct HotlistEntry *entry;
  119.  
  120.             data = INST_DATA(cl, obj);
  121.             for (i=0; ; i++) {
  122.                 DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, i, &entry);
  123.                 if (!entry) break;
  124.                 entry->Online = 0;
  125.                 DoMethod(data->LV_Hotlist, MUIM_NList_Redraw, i);
  126.             }
  127.             return NULL;
  128.             }
  129.         case HOTLIST_ADD:
  130.             {
  131.             struct HotlistEntry *entry;
  132.             char *buf;
  133.             data = INST_DATA(cl, obj);
  134.  
  135.             get(data->ST_Nick, MUIA_String_Contents, &buf);
  136.             if (buf && buf[0] != '\0' && (entry = malloc(sizeof(struct HotlistEntry)))) {
  137.                 entry->Online = 0;
  138.                 entry->Speed = 0;
  139.                 entry->Nick = strdup(buf);
  140.  
  141.                 DoMethod(data->LV_Hotlist, MUIM_NList_InsertSingle, entry, MUIV_NList_Insert_Sorted);
  142.                 if (gui_onlinestate == ONLINE) nap_sendbuf(NAPC_HOTLIST_ADD, entry->Nick);
  143.                 HotlistChanged = TRUE;
  144.             }
  145.             set(data->ST_Nick, MUIA_String_Contents, "");
  146.             }
  147.             return NULL;
  148.         case HOTLIST_REMOVE:
  149.             {
  150.             struct HotlistEntry *entry;
  151.             data = INST_DATA(cl, obj);
  152.  
  153.             DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &entry);
  154.             if (entry && gui_onlinestate == ONLINE) nap_sendbuf(NAPC_HOTLIST_REMOVE, entry->Nick);
  155.  
  156.             DoMethod(data->LV_Hotlist, MUIM_NList_Remove, MUIV_NList_Remove_Active);
  157.             HotlistChanged = TRUE;
  158.             return NULL;
  159.             }
  160.         case HOTLIST_BROWSE:
  161.             {
  162.             struct HotlistEntry *entry;
  163.             long showresults;
  164.             data = INST_DATA(cl, obj);
  165.  
  166.             get(data->TG_Results, MUIA_Selected, &showresults);
  167.             if (!showresults) {
  168.                 set(data->LV_Search, MUIA_ShowMe, TRUE);
  169.                 set(data->TG_Results, MUIA_Selected, TRUE);
  170.             }
  171.  
  172.             DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &entry);
  173.             if (entry) DoMethod(data->LV_Search, RESULTVIEW_NICK, entry->Nick);
  174.  
  175.             return NULL;
  176.             }
  177.         case HOTLIST_NICK:
  178.             {
  179.             u_long tmp;
  180.             data = INST_DATA(cl, obj);
  181.  
  182.             get(obj, MUIA_Window_Open, &tmp);
  183.             if (!tmp) set(obj, MUIA_Window_Open, TRUE);
  184.             /* Open the window if it's not already opened */
  185.  
  186.             get(data->TG_Results, MUIA_Selected, &tmp);
  187.             if (!tmp) {
  188.                 set(data->LV_Search, MUIA_ShowMe, TRUE);
  189.                 set(data->TG_Results, MUIA_Selected, TRUE);
  190.             }
  191.  
  192.             if ((char *)(((muimsg)msg)->arg1) == NULL) {
  193.                 GetAttr(MUIA_String_Contents, data->ST_Nick, &tmp);
  194.                 if (tmp && ((char *)tmp)[0] != '\0') DoMethod(data->LV_Search, RESULTVIEW_NICK, (char *)tmp);
  195.             }
  196.             else DoMethod(data->LV_Search, RESULTVIEW_NICK, (char *)(((muimsg)msg)->arg1));
  197.             return NULL;
  198.             }
  199.         case HOTLIST_FOUND:
  200.             data = INST_DATA(cl, obj);
  201.             DoMethod(data->LV_Search, RESULTVIEW_FOUND, ((muimsg)msg)->arg1);
  202.             return NULL;
  203.         case HOTLIST_TOGGLE_RESULTS:
  204.             {
  205.             u_long tmp;
  206.             data = INST_DATA(cl, obj);
  207.  
  208.             GetAttr(MUIA_Selected, data->TG_Results, &tmp);
  209.             if (tmp)
  210.                 set(data->LV_Search, MUIA_ShowMe, TRUE);
  211.             else
  212.                 set(data->LV_Search, MUIA_ShowMe, FALSE);
  213.             return NULL;
  214.             }
  215.         case HOTLIST_TOGGLE:
  216.             data = INST_DATA(cl, obj);
  217.             DoMethod(data->LV_Search, RESULTVIEW_TOGGLE_ONE);
  218.             return NULL;
  219.     }
  220.  
  221.     return(DoSuperMethodA(cl, obj, msg));
  222. }
  223.  
  224.  
  225. ULONG HotlistNew(struct IClass *cl, Object *obj, struct opSet *msg)
  226. {
  227.     static const struct Hook HotlistDispHook = { {NULL, NULL}, &HotlistDisplay,   NULL, NULL };
  228.     static const struct Hook HotlistCompHook = { {NULL, NULL}, &HotlistCompare,   NULL, NULL };
  229.     static const struct Hook HotlistDestHook = { {NULL, NULL}, &HotlistDestruct,  NULL, NULL };
  230.  
  231.     struct HotlistData *data;
  232.  
  233.     Object *LV_Hotlist, *LV_Search;
  234.     Object *BT_Add, *BT_Remove;
  235.     Object *ST_Nick, *BT_Browse;
  236.     Object *TG_Results;
  237.  
  238.     gColFormat = "COL=1 BAR, COL=2 BAR, COL=3 BAR, COL=4 BAR, COL=5 BAR, COL=6 BAR";
  239.  
  240.     if (obj = (Object *)DoSuperNew(cl, obj,
  241.         MUIA_HelpNode, "hotlist",
  242.         MUIA_Window_Title, MSG_HOTLIST_TITLE,
  243.         MUIA_Window_ID, MAKE_ID('H','O','T','L'),
  244.         WindowContents, HGroup,
  245.             Child, VGroup,
  246.                 MUIA_HorizWeight, 25,
  247.                 Child, NListviewObject,
  248.                     MUIA_NListview_NList, LV_Hotlist = NListObject,
  249.                         InputListFrame,
  250.                         MUIA_NList_ListBackground, MUII_ListBack,
  251.                         MUIA_NList_Title, TRUE,
  252.                         MUIA_NList_Format, "BAR,BAR,",
  253.                         MUIA_NList_DisplayHook, &HotlistDispHook,
  254.                         MUIA_NList_CompareHook2, &HotlistCompHook,
  255.                         MUIA_NList_DestructHook, &HotlistDestHook,
  256.                     End,
  257.                 End,
  258.                 Child, HGroup,
  259.                     Child, Label2(MSG_SEARCHUSER),
  260.                     Child, ST_Nick = StringObject,
  261.                         StringFrame,
  262.                         MUIA_HorizWeight, 400,
  263.                         MUIA_String_MaxLen, 20,
  264.                         MUIA_CycleChain, 1,
  265.                         MUIA_ShortHelp, MSG_SEARCHUSER_HELP,
  266.                     End,
  267.                 End,
  268.                 Child, HGroup,
  269.                     Child, BT_Add    = SimpleButton(MSG_HOTLIST_ADD_GAD),
  270.                     Child, BT_Remove = SimpleButton(MSG_HOTLIST_REMOVE_GAD),
  271.                     Child, BT_Browse = SimpleButton(MSG_SEARCHUSER_GAD),
  272.                 End,
  273.                 Child, HGroup,
  274.                     Child, TextObject,
  275.                         MUIA_HorizWeight, 25,
  276.                         MUIA_Text_PreParse, "\33r",
  277.                         MUIA_Text_Contents, MSG_HOTLIST_RESULTS,
  278.                     End,
  279.                     Child, TG_Results = ImageObject,
  280.                         ButtonFrame,
  281.                         MUIA_HorizWeight, 10,
  282.                         MUIA_Background, MUII_ButtonBack,
  283.                         MUIA_InputMode, MUIV_InputMode_Toggle,
  284.                         MUIA_ShowSelState, FALSE,
  285.                         MUIA_Image_Spec, "6:15",
  286.                         MUIA_Selected, FALSE,
  287.                     End,
  288.                 End,
  289.             End,
  290.             Child, BalanceObject, End,
  291.             Child, LV_Search = NewObject(gui->resultview_mcc->mcc_Class, NULL, TAG_DONE),
  292.         End,
  293.         TAG_MORE, msg->ops_AttrList))
  294.     {
  295.         data = INST_DATA(cl, obj);
  296.         data->LV_Hotlist = LV_Hotlist;
  297.         data->LV_Search  = LV_Search;
  298.         data->TG_Results = TG_Results;
  299.         data->ST_Nick    = ST_Nick;
  300.  
  301.         lamp_useinlist(LV_Hotlist);
  302.  
  303.         DoMethod(obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, obj, 3, MUIM_Set, MUIA_Window_Open, FALSE);
  304.  
  305.         DoMethod(BT_Add,    MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, HOTLIST_ADD);
  306.         DoMethod(BT_Remove, MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, HOTLIST_REMOVE);
  307.         DoMethod(BT_Browse, MUIM_Notify, MUIA_Pressed, FALSE, obj, 2, HOTLIST_NICK, NULL);
  308.         DoMethod(ST_Nick,   MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, obj, 2, HOTLIST_NICK, NULL);
  309.  
  310.         DoMethod(LV_Hotlist, MUIM_Notify, MUIA_NList_DoubleClick, MUIV_EveryTime, obj, 1, HOTLIST_BROWSE);
  311.         DoMethod(TG_Results, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, obj, 1, HOTLIST_TOGGLE_RESULTS);
  312.  
  313.         LoadHotlist(data);
  314.  
  315.         /* Default sort */
  316.  
  317.         DoMethod(LV_Hotlist, MUIM_Set, MUIA_NList_TitleMark, 1);
  318.         DoMethod(LV_Hotlist, MUIM_NList_Sort3, 1, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_Both);
  319.  
  320.         DoMethod(LV_Hotlist, MUIM_Notify, MUIA_NList_TitleClick,  MUIV_EveryTime, LV_Hotlist, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_Both);
  321.         DoMethod(LV_Hotlist, MUIM_Notify, MUIA_NList_TitleClick2, MUIV_EveryTime, LV_Hotlist, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_2);
  322.         DoMethod(LV_Hotlist, MUIM_Notify, MUIA_NList_SortType,    MUIV_EveryTime, LV_Hotlist, 3, MUIM_Set, MUIA_NList_TitleMark,  MUIV_TriggerValue);
  323.         DoMethod(LV_Hotlist, MUIM_Notify, MUIA_NList_SortType2,   MUIV_EveryTime, LV_Hotlist, 3, MUIM_Set, MUIA_NList_TitleMark2, MUIV_TriggerValue);
  324.  
  325.         set(data->LV_Search, MUIA_ShowMe, FALSE);
  326.  
  327.         return((ULONG)obj);
  328.     }
  329.     return(0);
  330. }
  331.  
  332.  
  333. MUIF HotlistDisplay(REG(a2) char **array, REG(a1) struct HotlistEntry *entry)
  334. {
  335.     if (entry) {
  336.         *array++ = entry->Nick;
  337.         if (entry->Online) *array++ = "\33bOnline";
  338.         else *array++ = "Offline";
  339. /*
  340.         if (entry->Online) *array++ = lamp_getforlist(4);
  341.         else *array++ = lamp_getforlist(2);
  342. */
  343.         *array = nap_linktype[entry->Speed];
  344.     }
  345.     else {
  346.         *array++ = (char *)MSG_HOTLIST_NICK;
  347.         *array++ = (char *)MSG_HOTLIST_STATUS;
  348.         *array   = (char *)MSG_HOTLIST_LINK;
  349.     }
  350.  
  351.     return NULL;
  352. }
  353.  
  354.  
  355. MUIF HotlistCompare(REG(a0) struct Hook *hook, REG(a2) Object *obj, REG(a1) struct NList_CompareMessage *ncm)
  356. {
  357.     struct HotlistEntry *entry1 = ncm->entry1;
  358.     struct HotlistEntry *entry2 = ncm->entry2;
  359.     LONG col1 = ncm->sort_type & MUIV_NList_TitleMark_ColMask;
  360.     LONG col2 = ncm->sort_type2 & MUIV_NList_TitleMark2_ColMask;
  361.     ULONG result = 0;
  362.  
  363.     if (ncm->sort_type == MUIV_NList_SortType_None) return (0);
  364.  
  365.     if (col1 == 0) {
  366.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  367.             result = (LONG) stricmp(entry2->Nick, entry1->Nick);
  368.         else
  369.             result = (LONG) stricmp(entry1->Nick, entry2->Nick);
  370.     }
  371.     else if (col1 == 1) {
  372.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  373.             result = entry1->Online - entry2->Online;
  374.         else
  375.             result = entry2->Online - entry1->Online;
  376.     }
  377.     else if (col1 == 2) {
  378.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  379.             result = entry2->Speed - entry1->Speed;
  380.         else
  381.             result = entry1->Speed - entry2->Speed;
  382.     }
  383.  
  384.     if ((result != 0) || (col1 == col2)) return (result);
  385.  
  386.     if (col2 == 0) {
  387.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  388.             result = (LONG) stricmp(entry2->Nick, entry1->Nick);
  389.         else
  390.             result = (LONG) stricmp(entry1->Nick, entry2->Nick);
  391.     }
  392.     else if (col2 == 1) {
  393.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  394.             result = entry1->Online - entry2->Online;
  395.         else
  396.             result = entry2->Online - entry1->Online;
  397.     }
  398.     else if (col2 == 2) {
  399.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  400.             result = entry2->Speed - entry1->Speed;
  401.         else
  402.             result = entry1->Speed - entry2->Speed;
  403.     }
  404.  
  405.     return (result);
  406. }
  407.  
  408.  
  409. MUIF HotlistDestruct(REG(a2) APTR pool, REG(a1) struct HotlistEntry *entry)
  410. {
  411.     free(entry);
  412.     return NULL;
  413. }
  414.  
  415.  
  416. void LoadHotlist(struct HotlistData *data)
  417. {
  418.     BPTR fh;
  419.     char buf[1024];
  420.     int line = 0;
  421.     struct HotlistEntry *entry;
  422.     LONG argarray[] = { NULL, NULL };
  423.     UBYTE *argstr = "NICK/K/A,SPEED/K/N";
  424.     struct RDArgs *rdargs;
  425.  
  426.     if (fh = Open("PROGDIR:Amster.hotlist", MODE_OLDFILE)) {
  427.         while (FGets(fh, buf, sizeof(buf))) {
  428.             line++;
  429.             if (rdargs = AllocDosObject(DOS_RDARGS, NULL)) {
  430.                 rdargs->RDA_Buffer = NULL;
  431.                 rdargs->RDA_Source.CS_Buffer = buf;
  432.                 rdargs->RDA_Source.CS_Length = strlen(buf);
  433.                 argarray[1] = NULL;
  434.                 if (ReadArgs(argstr, argarray, rdargs)) {
  435.                     if (entry = malloc(sizeof(struct HotlistEntry))) {
  436.                         entry->Nick = strdup((char *)argarray[0]);
  437.                         if (argarray[1]) entry->Speed = *((long *)argarray[1]);
  438.                         else entry->Speed = 0;
  439.                         entry->Online = 0;
  440.                         DoMethod(data->LV_Hotlist, MUIM_NList_InsertSingle, entry, MUIV_NList_Insert_Sorted);
  441.  
  442.                         if (gui_onlinestate == ONLINE) nap_sendbuf(NAPC_HOTLIST_INIT, entry->Nick);
  443.                     }
  444.                 }
  445.                 else gui_debugf((char *)MSG_PARSE_ERROR, "PROGDIR:Amster.hotlist", line);
  446.                 FreeDosObject(DOS_RDARGS, rdargs);
  447.             }
  448.         }
  449.         Close(fh);
  450.         DoMethod(data->LV_Hotlist, MUIM_NList_Sort);
  451.     }
  452. }
  453.  
  454.  
  455. void SaveHotlist(struct HotlistData *data)
  456. {
  457.     struct HotlistEntry *entry;
  458.     BPTR fh;
  459.     char buf[1024];
  460.     int i;
  461.  
  462.     fh = Open("PROGDIR:Amster.hotlist", MODE_NEWFILE);
  463.     if (!fh) return;
  464.  
  465.     for (i=0; ; i++) {
  466.         DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, i, &entry);
  467.         if (!entry) break;
  468.         sprintf(buf, "NICK \"%s\" SPEED %d\n", entry->Nick, entry->Speed);
  469.         Write(fh, buf, strlen(buf)); /* Should be buffered, check FWrite */
  470.     }
  471.  
  472.     Close(fh);
  473.     HotlistChanged = FALSE;
  474. }
  475.  
  476.  
  477. void UploadHotlist(struct HotlistData *data)
  478. {
  479.     struct HotlistEntry *entry;
  480.     int i;
  481.  
  482.     if (gui_onlinestate < LOGGING_IN) return;
  483.  
  484.     for (i=0; ; i++) {
  485.         DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, i, &entry);
  486.         if (!entry) break;
  487.         nap_sendbuf(NAPC_HOTLIST_INIT, entry->Nick);;
  488.     }
  489. }
  490.  
  491.  
  492. void HotlistInterpret(u_int com, char *data)
  493. {
  494.     char *nick;
  495.     int speed;
  496.  
  497.     switch(com) {
  498.         case NAPC_USER_SIGNON:
  499.             nick = nap_token(&data);
  500.             speed = atoi(data);
  501.             DoMethod(gui->WI_Hotlist, HOTLIST_SIGNON, nick, speed);
  502.             break;
  503.         case NAPC_USER_SIGNOFF:
  504. gui_debugf((char *)MSG_INFO_SIGNOFF, data);
  505.             DoMethod(gui->WI_Hotlist, HOTLIST_SIGNOFF, data);
  506.             break;
  507.         case NAPC_HOTLIST_ACK:
  508. gui_debugf("User %s succesfully added to hotlist", data);
  509.             break;
  510.         case NAPC_HOTLIST_ERROR:
  511. gui_debugf("Error adding %s to hotlist", data);
  512.             break;
  513.     }
  514. }
  515.  
  516.  
  517. struct HotlistEntry *GetHotlistEntry(struct HotlistData *data, char *nick)
  518. {
  519.     struct HotlistEntry *entry;
  520.     int i;
  521.  
  522.     for (i=0; ; i++) {
  523.         DoMethod(data->LV_Hotlist, MUIM_NList_GetEntry, i, &entry);
  524.         if (!entry) return NULL;
  525.         if (stricmp(entry->Nick, nick) == 0) break;
  526.     }
  527.  
  528.     return entry;
  529. }
  530.